#include <algorithm>
#include <iostream>

using namespace std;
const int N = 1e5 + 5;

int arr[N], n, q;
int p[N];
signed main() {
    
    while (~scanf("%d %d", &n, &q)) {
        memset(p, 0, size(p[0]) * n + 8);
        int res = 0;
        for (int i = 1; i <= n; ++ i) {
            scanf("%d", arr + i);
            if (!p[arr[i]]) res ++;
            p[arr[i]] ++;
        }
        for (int i = 1; i <= q; ++ i) {
            int l, r;
            scanf("%d %d", &l, &r);
            if (l >= r) printf("%d\n", res);
            else {
                
            }
        }
    }



    return 0;
}